/*
 *------------------------------------------------------------------------------
 * @File      :    ei_mai_disp_define.h
 * @Date      :    2021-4-8
 * @Author    :    lomboswer <lomboswer@lombotech.com>
 * @Brief     :    Media Interface for MADP(Media Development Platform).
 *
 * Copyright (C) 2020-2021, LomboTech Co.Ltd. All rights reserved.
 *------------------------------------------------------------------------------
 */

#ifndef __EI_MAI_DISP_DEFINE_H__
#define __EI_MAI_DISP_DEFINE_H__

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif

#define EI_MAI_ERR_DISP_NULL_PTR        EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_NULL_PTR)
#define EI_MAI_ERR_DISP_NOTREADY        EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_SYS_NOTREADY)
#define EI_MAI_ERR_DISP_INVALID_DEVID   EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_INVALID_DEVID)
#define EI_MAI_ERR_DISP_INVALID_CHNID   EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_INVALID_CHNID)
#define EI_MAI_ERR_DISP_EXIST           EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_EXIST)
#define EI_MAI_ERR_DISP_UNEXIST         EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_UNEXIST)
#define EI_MAI_ERR_DISP_NOT_SUPPORT     EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_NOT_SUPPORT)
#define EI_MAI_ERR_DISP_NOT_PERM        EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_NOT_PERM)
#define EI_MAI_ERR_DISP_NOMEM           EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_NOMEM)
#define EI_MAI_ERR_DISP_NOBUF           EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_NOBUF)
#define EI_MAI_ERR_DISP_ILLEGAL_PARAM   EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_ILLEGAL_PARAM)
#define EI_MAI_ERR_DISP_BUSY            EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_BUSY)
#define EI_MAI_ERR_DISP_BUF_EMPTY       EI_MADP_DEF_ERR(EI_MADP_MOD_DISP, MADP_EN_ERR_LEVEL_ERROR, MADP_EN_ERR_BUF_EMPTY)


typedef EI_S32 EI_MADP_DISP_INTF_TYPE_E;
#define DISP_INTF_CVBS        (0x01L<<0)
#define DISP_INTF_BT656       (0x01L<<3)
#define DISP_INTF_BT1120      (0x01L<<4)
#define DISP_INTF_HDMI        (0x01L<<5)
#define DISP_INTF_LCD_6BIT    (0x01L<<9)
#define DISP_INTF_LCD_8BIT    (0x01L<<10)
#define DISP_INTF_LCD_16BIT   (0x01L<<11)
#define DISP_INTF_LCD_24BIT   (0x01L<<12)


typedef enum eiMADP_DISP_INTF_SYNC_E
{
	DISP_SYNC_PAL = 0,
	DISP_SYNC_NTSC,

	DISP_SYNC_1080P24,
	DISP_SYNC_1080P25,
	DISP_SYNC_1080P30,

	DISP_SYNC_720P50,
	DISP_SYNC_720P60,
	DISP_SYNC_1080I50,
	DISP_SYNC_1080I60,
	DISP_SYNC_1080P50,
	DISP_SYNC_1080P60,

	DISP_SYNC_576P50,
	DISP_SYNC_480P60,

	DISP_SYNC_800x600_60,
	DISP_SYNC_1024x768_60,
	DISP_SYNC_1280x1024_60,
	DISP_SYNC_1366x768_60,
	DISP_SYNC_1440x900_60,
	DISP_SYNC_1280x800_60,
	DISP_SYNC_1600x1200_60,
	DISP_SYNC_1680x1050_60,
	DISP_SYNC_1920x1200_60,
	DISP_SYNC_640x480_60,
	DISP_SYNC_960H_PAL,
	DISP_SYNC_960H_NTSC,
	DISP_SYNC_1920x2160_30,
	DISP_SYNC_2560x1440_30,
	DISP_SYNC_2560x1440_60,
	DISP_SYNC_2560x1600_60,
	DISP_SYNC_3840x2160_24,
	DISP_SYNC_3840x2160_25,
	DISP_SYNC_3840x2160_30,
	DISP_SYNC_3840x2160_50,
	DISP_SYNC_3840x2160_60,
	DISP_SYNC_4096x2160_24,
	DISP_SYNC_4096x2160_25,
	DISP_SYNC_4096x2160_30,
	DISP_SYNC_4096x2160_50,
	DISP_SYNC_4096x2160_60,
	DISP_SYNC_320x240_60,
	DISP_SYNC_320x240_50,
	DISP_SYNC_240x320_50,
	DISP_SYNC_240x320_60,
	DISP_SYNC_800x600_50,
	DISP_SYNC_720x1280_60,
	DISP_SYNC_1080x1920_60,
	DISP_SYNC_7680x4320_30,
	DISP_SYNC_USER,

	DISP_SYNC_BUTT

} EI_MADP_DISP_INTF_SYNC_E;

typedef struct eiEI_MADP_DISP_SYNC_INFO_S {
	EI_BOOL bSynm; /* RW; sync mode(0:timing,as BT.656; 1:signal,as LCD) */
	EI_BOOL bIop; /* RW; interlaced or progressive display(0:i; 1:p) */
	EI_U8 u8Intfb; /* RW; interlace bit width while output */

	EI_U16 u16Vact; /* RW; vertical active area */
	EI_U16 u16Vbb; /* RW; vertical back blank porch */
	EI_U16 u16Vfb; /* RW; vertical front blank porch */

	EI_U16 u16Hact; /* RW; horizontal active area */
	EI_U16 u16Hbb; /* RW; horizontal back blank porch */
	EI_U16 u16Hfb; /* RW; horizontal front blank porch */
	EI_U16 u16Hmid; /* RW; bottom horizontal active area */

	EI_U16 u16Bvact; /* RW; bottom vertical active area */
	EI_U16 u16Bvbb; /* RW; bottom vertical back blank porch */
	EI_U16 u16Bvfb; /* RW; bottom vertical front blank porch */

	EI_U16 u16Hpw; /* RW; horizontal pulse width */
	EI_U16 u16Vpw; /* RW; vertical pulse width */

	EI_U32 u32Pclk; /* RW; pixel clock */

	EI_BOOL bIdv; /* RW; inverse data valid of output */
	EI_BOOL bIhs; /* RW; inverse horizontal synch signal */
	EI_BOOL bIvs; /* RW; inverse vertical synch signal */
	EI_BOOL bICv; /* RW; inverse pixel clock valid of output */

	/* setup CPU-I8080 interface */
	EI_BOOL bHasHsyncCmd; /* RW; with hsync cmd for each line */
	EI_BOOL bHasVsyncCmd; /* RW; with vsync cmd for each frame */
	EI_BOOL bHasTE; /* RW; with TE signal for each frame */
	EI_BOOL bTEPol; /* RW; POL of TE signal */
	EI_U32 u32CmdAlign; /* RW; align for sync cmd */

	/* setup LVDS interface */
	EI_BOOL bDataMirror; /* RW; lvds data order(0:MSB first; 1:LSB first) */
} EI_MADP_DISP_SYNC_INFO_S;

typedef struct eiMADP_DISP_ATTR_S {
	EI_MADP_DISP_INTF_TYPE_E enIntfType;
	EI_MADP_DISP_INTF_SYNC_E enIntfSync;
	EI_MADP_DISP_SYNC_INFO_S stSyncInfo;
} EI_MADP_DISP_ATTR_S;

typedef struct eiMADP_DISP_WINDOW_ATTR_S {
	EI_MADP_RECT_S stRect;
	EI_U32 u32Priority;
} EI_MADP_DISP_WINDOW_ATTR_S;

typedef enum eiMADP_DISP_ROTATE_E {
	EI_MADP_ROTATE_NONE = 0,
	EI_MADP_ROTATE_90   = 1,
	EI_MADP_ROTATE_180  = 2,
	EI_MADP_ROTATE_270  = 3,
	EI_MADP_ROTATE_BUTT
} EI_MADP_DISP_ROTATE_E;

typedef struct eiMADP_DISP_ROTATEATTREX_S {
	EI_MADP_DISP_ROTATE_E enDispRorate;
} EI_MADP_DISP_ROTATEATTREX_S;

typedef enum eiEI_MADP_DISP_CMD_E
{
	EI_MADP_DISP_CMD_CreateOsd,
	EI_MADP_DISP_CMD_SetOsd,
	EI_MADP_DISP_CMD_DestroyOsd,
	EI_MADP_DISP_CMD_CreateRect,
	EI_MADP_DISP_CMD_DestroyRect,
	EI_MADP_DISP_CMD_CreateMasaic,
	EI_MADP_DISP_CMD_DestroyMasaic,
	EI_MADP_DISP_CMD_CreateCover,
	EI_MADP_DISP_CMD_DestroyCover,
	EI_MADP_DISP_CMD_BUTT
} EI_MADP_DISP_CMD_E;

typedef struct eiDISP_ATTREX_S
{
	EI_HANDLE handle;			/* handle for Osd, rect, cover, 0 ~ 127 */
	union {
		EI_MADP_OSD_ATTR_S stOsdAttr;
		EI_MADP_RECT_ATTR_S stRectAttr;
		EI_MADP_MOSAIC_ATTR_S stMosaicAttr;
		EI_MADP_COVER_ATTR_S stCoverAttr;
	};
} DISP_ATTREX_S;

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

#endif
